import {PageContainer} from '@ant-design/pro-layout';
import {Button} from 'antd';
import ProTable from '@ant-design/pro-table';
import {getCashier} from "@/services/ant-design-pro/order";
import {useRef} from "react";

const CashierOrder = () => {
    const actionRef = useRef()
    const columns: any = [
    {
        title: '订单号',
        dataIndex: 'order_number',
        align: 'center',
    },
    {
        title: '用户信息',
        dataIndex: 'nickname',
        align: 'center',
        render: (_, record) => [
            <div>{record.user.nickname}</div>
        ]

    },
    {
        title: '实际支付',
        dataIndex: 'pay_price',
        align: 'center',
        search: false
    },
    {
        title: '优惠价格',
        dataIndex: 'deduction_price',
        align: 'center',
        search: false
    },
    {
        title: '支付时间',
        dataIndex: 'pay_time',
        valueType: 'date',
        align: 'center',
    },

    ]
    return (
        <PageContainer
            header={{breadcrumb: {}}}
        >
            <div style={{background: 'white', padding: '10px', paddingTop: '15px'}}>
                <ProTable
                    columns={columns}
                    rowKey="uid"
                    actionRef={actionRef}
                    request={async (params = {}, sort, filter) => {
                        let {data, meta} = await getCashier({...params, ...sort, ...filter,})
                        return {
                            data,
                            success: true,
                            total: meta.pagination.total
                        };
                    }}
                    dateFormatter="string"
                    toolBarRender={() => [
                        <Button type="primary" key="primary">
                            查看二维码
                        </Button>,
                    ]}
                />
            </div>
        </PageContainer>
    );
};

export default CashierOrder;
